package com.wyp168.leetcode.entity;

/**
 * @ClassName Count
 * @Title TODO
 * @Description TODO
 * @Author wyp168
 * @Date 2022/10/10 19:15
 */
public class Count {
    public static void main(String[] args) {
        Count count = new Count();
        String s = "ABCCC";
        String subString = "d";
        System.out.println(count.count(s, subString));
    }

    public int count(String s, String subString) {
        int result = 0;
        int leftIndex = 0;
        s = s.toLowerCase();
        subString = subString.toLowerCase();
        while (leftIndex < s.length() && leftIndex >= 0 && (leftIndex = s.indexOf(subString, leftIndex) + 1) != 0) {
            result ++;
        }
        return result;
    }
}
